package com.qf.dao.impl;


import com.qf.dao.AdminDao;
import com.qf.pojo.Admin;
import com.qf.utils.DruidUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class AdminDaoImpl implements AdminDao {
    //创建jdbcTemplate，获取数据源
   private  JdbcTemplate jdbcTemplate=new JdbcTemplate(DruidUtil.getDataSource());

    @Override
    public List<Admin> findAdmian(String name,String password) {
        String sql="select * from admin where username=? and password=?";
        List<Admin> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Admin.class), name, password);
        if(query.size()>0){
            return query;
        }
        return null;
    }
}
